package com.bangdream.michelia.tool.retrofithttp;

import com.bangdream.michelia.entity.BaseEntity;
import com.bangdream.michelia.entity.CertBean;
import com.bangdream.michelia.entity.CollectionBean;
import com.bangdream.michelia.entity.CollectionRecordBean;
import com.bangdream.michelia.entity.CommentBean;
import com.bangdream.michelia.entity.DomainBean;
import com.bangdream.michelia.entity.FinishedStateBean;
import com.bangdream.michelia.entity.LearningBean;
import com.bangdream.michelia.entity.LearningStateBean;
import com.bangdream.michelia.entity.LiveUrlBean;
import com.bangdream.michelia.entity.MyExamBean;
import com.bangdream.michelia.entity.PayStatusBean;
import com.bangdream.michelia.entity.ReplayBean;
import com.bangdream.michelia.entity.STSBean;
import com.bangdream.michelia.entity.SignUpBean;
import com.bangdream.michelia.entity.TaskCurriculumBean;
import com.bangdream.michelia.entity.TrainPlanDetail;
import com.bangdream.michelia.entity.UserMsgBean;
import com.bangdream.michelia.entity.courses.BuyCourseBean;
import com.bangdream.michelia.entity.courses.CourseInfoBean;
import com.bangdream.michelia.entity.courses.VideoMsgBean;
import com.bangdream.michelia.entity.exam.ExamBean;
import com.bangdream.michelia.entity.MessageBean;
import com.bangdream.michelia.entity.TrainPlanBean;
import com.bangdream.michelia.entity.courses.CoursesBean;
import com.bangdream.michelia.entity.CoursesTypeBean;
import com.bangdream.michelia.entity.ErrorMessageBean;
import com.bangdream.michelia.entity.LiveBean;
import com.bangdream.michelia.entity.RecommendBean;
import com.bangdream.michelia.entity.TeacherBean;
import com.bangdream.michelia.entity.UserInfoBean;
import com.bangdream.michelia.entity.exam.ExamQuestBean;
import com.bangdream.michelia.entity.exam.ExamResultDetailsBean;
import com.bangdream.michelia.entity.exam.ExamResultItemBean;
import com.bangdream.michelia.entity.exam.SubjectBean;
import com.bangdream.michelia.entity.exam.SubjectInfoBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

/**
 * Created by Mr.Wang on 2017/9/15.
 * 909732184@qq.com
 */

public interface ApiService {

//    String baseUrl = "http://218.80.205.234:5000/";
    String baseUrl = "http://122.144.211.63:5000/";
//    String baseUrl = "http://218.80.205.238:5000/";
    //String baseUrl = "http://218.80.3.100/";

//   @FormUrlEncoded
//    @POST("APPAccount/ValidUserResource")
//    Observable<ResponseBody> UserSignIn(@Field("userName")String username, @Field("password")String password);
    //查询表中单条数据
    @FormUrlEncoded
    @POST("Form/FormLoad")

    Observable<ResponseBody> FormLoad(@FieldMap Map<String, String> map);

    @FormUrlEncoded
    @POST("Form/FormLoad")
    Observable<ResponseBody> getAdMessage(@FieldMap Map<String, String> map);

    //下载文件http://www.jianshu.com/p/582e0a4a4ee9
    @Streaming
    @GET
    Observable<ResponseBody> downloadFile(@Url String fileUrl);

    //将错误装换为文本
    @GET("bylBaseCenter/dict/getDict")
    Observable<BaseEntity<ErrorMessageBean>> getDict(@Query("type") String type, @Query("value") String value);

    //用户注册获取验证码
    @GET("bylBaseCenter/register/code/{phone}")
    Observable<ResponseBody> getRegisterCode(@Path("phone") String stPhone);

    //获取登录手机验证码  用于用户名密码登录失败三次之后，需要输入验证码
    @GET("bylBaseCenter/login/code")
    Observable<ResponseBody> getLoginPhoneCode(@Query("phone") String stPhone);

    //验证码登录获取验证码
    @GET("bylBaseCenter/login/phone/code")
    Observable<ResponseBody> getCodeLoginCode(@Query("phone") String stPhone);

    //验证码登录
    @POST("bylBaseCenter/login/phone")
    Observable<BaseEntity<UserInfoBean>> actionCodeLogin(@Body RequestBody body);

    //第三方登录
    @POST("bylBaseCenter/login/third")
    Observable<BaseEntity<UserInfoBean>> actionThirdLogin(@Body RequestBody body);

    //找回密码获取验证码
    @GET("bylBaseCenter/findPassword/phone/code")
    Observable<ResponseBody> getFindPasswordCode(@Query("phone") String stPhone);

    //修改密码
    @POST("bylBaseCenter/user/edit/password")
    Observable<BaseEntity> editPwd(@Query("token") String token,@Body RequestBody body);

    //找回密码
    @POST("bylBaseCenter/findPassword/validate-phone")
    @Headers("Content-Type:application/json; charset=utf-8")
    Observable<ResponseBody> actionFindPassword(@Body RequestBody body);

    //用户注册
    @POST("bylBaseCenter/register/phone")
    Observable<ResponseBody> actionRegister(@Body RequestBody body);

    //用户登录
    @POST("bylBaseCenter/login/username")
    Observable<BaseEntity<UserInfoBean>> actionLogin(@Body RequestBody body);

    //登出
    @GET("bylBaseCenter/user/logout")
    Observable<ResponseBody> loginOut(@Query("token") String token);

    //获取机构信息
    @POST("bylBusiness/entInfo/searchByUser")
    Observable<BaseEntity<List<DomainBean>>> getDomain(@Query("token") String token,@Body RequestBody body);

    //课程列表
    @POST("course-center/course/courses")
    Observable<BaseEntity<List<CoursesBean>>> getCoursesList(@Query("token") String token,@Body()RequestBody requestBody);


    //获取用户已学习课程、未完成课程
    @POST("course-center/course/learn/list")
    Observable<BaseEntity<List<CoursesBean>>> getList(@Query("token") String token, @Body()RequestBody requestBody);

    //考试列表
    @POST("examCenter/examPaper/searchByUser")
    Observable<BaseEntity<List<ExamBean>>> getExamList(@Query("token") String token, @Body()RequestBody requestBody);


    //绑定计划中的考试
    @POST("bylBusiness/planUsers/saveExamId")
    Observable<BaseEntity> bindExamByTran(@Query("token") String token, @Body()RequestBody requestBody);


    //问卷列表
    @POST("examCenter/examPaper/searchByUser")
    Observable<BaseEntity<List<ExamBean>>> getExamQuList(@Query("token") String token, @Body()RequestBody requestBody);

    //问卷详情列表
    @POST("examCenter/examQuestion/getListByExam")
    Observable<BaseEntity<List<ExamQuestBean>>> getExamQuestList(@Query("token") String token, @Body()RequestBody requestBody);

    //创建考试id
    @POST("examCenter/examExamScore/getExamId")
    Observable<BaseEntity<String>> actionInitExamId(@Query("token") String token, @Body()RequestBody requestBody);

    //提交答题信息
    @POST("examCenter/examExamScoreInfo/save")
    Observable<ResponseBody> actionSubmitExam(@Query("token") String token, @Body()RequestBody requestBody);

    //提交问卷信息
    @POST("examCenter/examExamScoreInfo/saveAll")
    Observable<ResponseBody> actionSubmitQuest(@Query("token") String token, @Body()RequestBody requestBody);

    //获取试题结果详情
    @POST("examCenter/examExamScore/getPaperResult")
    Observable<BaseEntity<ExamResultDetailsBean>> getExamResultDetails(@Query("token") String token, @Body()RequestBody requestBody);

    //获取试题结果列表
    @POST("examCenter/examExamScoreInfo/search")
    Observable<BaseEntity<List<ExamResultItemBean>>> getExamResult(@Query("token") String token, @Body()RequestBody requestBody);

    //获取试卷包含的试题集
    @POST("examCenter/examExamScoreInfo/search")
    Observable<BaseEntity<List<SubjectBean>>> getSubjectList(@Query("token") String token,@Body()RequestBody requestBody);

    //获取单个试题信息
    @POST("examCenter/examQuestion/getByExam")
    Observable<BaseEntity<SubjectInfoBean>> getSubjectDetails(@Query("token") String token, @Body()RequestBody requestBody);

    //我的考试
    @POST("examCenter/examPaper/searchByUserOnly")
    Observable<BaseEntity<List<ExamBean>>> getMyExam(@Query("token") String token, @Body()RequestBody requestBody);


    //获取讲师的课程列表
    @POST("course-center/course/courses/teacher/page")
    Observable<BaseEntity<List<CoursesBean>>> getTeacherCoursesList(@Query("token") String token,@Body()RequestBody requestBody);

    //获取课程的评论列表
    @POST("bylBusiness/page/comments")
//    @POST("course-center/comment/page/course/comments")
    Observable<BaseEntity<List<CommentBean>>> getCommentList(@Query("token") String token, @Body()RequestBody requestBody);

    //获取收藏的课程列表
    @POST("course-center/course/collect/collects")
    Observable<BaseEntity<List<CollectionBean>>> getCollectList(@Query("token") String token, @Body()RequestBody requestBody);

    //收藏课程
    @POST("course-center/course/collect")
    Observable<BaseEntity<CollectionRecordBean>> actionCollection(@Query("token") String token, @Body()RequestBody requestBody);

    //取消收藏
    @GET("course-center/course/collect/delete/{id}")
    Observable<BaseEntity> actionCancelCollection(@Path("id") String id,@Query("token") String token);

    //学习记录
    @POST("course-center/course/learn/list")
    Observable<BaseEntity<List<LearningBean>>> getLearnList(@Query("token") String token, @Body()RequestBody requestBody);

    //评论
    @POST("bylBusiness/course/comment")
    Observable<BaseEntity<CommentBean>> actionComment(@Query("token") String token, @Body()RequestBody requestBody);

    //课程类型列表
    @POST("course-center/course/classification/list")
    @Headers("Content-Type:application/json; charset=utf-8")
    Observable<BaseEntity<List<CoursesTypeBean>>> getCoursesTypeList(@Query("token") String token);

    //课程详情
    @GET("course-center/course/get/{id}")
    Observable<BaseEntity<CoursesBean>> getCoursesDetails(@Path("id") String id,@Query("token") String token);

    //课程学习保存进度
    @POST("bylBusiness/course/learn")
    Observable<String> saveLearn(@Query("token") String token, @Body()RequestBody requestBody);

    //课程信息
    @POST("bylBusiness/course/chapter/info")
    Observable<BaseEntity<CourseInfoBean>> getCourseInfo(@Query("token") String token, @Body()RequestBody requestBody);

    //我的证书
    @POST("bylBusiness/cert/search")
    Observable<BaseEntity<List<CertBean>>> getCertList(@Query("token") String token, @Body()RequestBody requestBody);

    //学习状态
    @POST("bylBusiness/userstate/learningstate")
    Observable<BaseEntity<LearningStateBean>> getLearningstate(@Query("token") String token, @Body()RequestBody requestBody);

    //获取个人学习完成情况
    @POST("bylBusiness/userstate/finishedstate")
    Observable<BaseEntity<FinishedStateBean>> getFinishstate(@Query("token") String token, @Body()RequestBody requestBody);

    //视频信息
    @GET("resource-center/resource/view/{id}")
    Observable<BaseEntity<VideoMsgBean>> getVideoMsg(@Path("id") String id, @Query("token") String token);

    //视频地址
    @GET("resource-center/resource/{id}")
    Observable<BaseEntity<CoursesBean>> getVideoUrl(@Path("id") String id,@Query("token") String token);


    //培训计划列表
//    @POST("bylBusiness/planUsers/search")
    @POST("bylBusiness/studyItemPermissions/myTasks")
    Observable<BaseEntity<List<TrainPlanBean>>> getTrainPlanList(@Query("token") String token, @Body RequestBody body);

    @POST("bylBusiness/planUsers/checkLearningSequence/{itemId}")
    @Headers("Content-Type:application/json; charset=utf-8")
    Observable<BaseEntity> checkLearningSequence( @Path("itemId") String itemId,@Query("token") String token,@Body RequestBody body);

    //任务 -> 课程
    @POST("bylBusiness/studyItemPermissions/myTasks")
    Observable<BaseEntity<List<TaskCurriculumBean>>> getTaskCurriculumList(@Query("token") String token, @Body RequestBody body);

    //任务 -> 考试
    @POST("bylBusiness/studyItemPermissions/myTasks")
    Observable<BaseEntity<List<ExamBean>>> getTaskExamList(@Query("token") String token, @Body RequestBody body);

    //任务 -> 问卷
    @POST("bylBusiness/studyItemPermissions/myTasks")
    Observable<BaseEntity<List<ExamBean>>> getQuestionList(@Query("token") String token, @Body RequestBody body);

    //培训计划详情
    @GET("bylBusiness/planUsers/{planUserId}")
    Observable<BaseEntity<TrainPlanBean>> getTrainPlanDetails(@Path("planUserId") String planUserId,@Query("token") String token,@Body RequestBody body);

    //
    @POST("bylBusiness/planUsers/getOne")
    Observable<BaseEntity<TrainPlanDetail>> getTrainPlanDetail( @Query("token") String token, @Body RequestBody body);


    //直播列表
    @POST("liveplaycenter/livePlayInfo/findList")
    Observable<BaseEntity<List<LiveBean>>> getLiveList(@Query("token") String token,@Body RequestBody body);

    //直播详情
    @GET("liveplaycenter/livePlayInfo/get")
    Observable<BaseEntity<LiveBean>> getLiveDetails(@Query("token") String token,@Query("id")String id);

    //直播地址
    @POST("liveplaycenter/livePlayInfo/getUserPlayUrl")
    Observable<BaseEntity<List<String>>> getLiveUrl(@Query("token") String token,@Body RequestBody body);

    //直播回看地址
    @POST("liveplaycenter/livePlayInfo/getUserReviewUrl")
    Observable<BaseEntity<List<ReplayBean>>> getReplayLiveUrl(@Query("token") String token, @Body RequestBody body);

    //保存观看直播状态
    @POST("liveplaycenter/livePlayState/save")
    Observable<String> saveLiveState(@Query("token") String token,@Body RequestBody body);

    //讲师列表
    @POST("course-center/teacher/teachers")
    Observable<BaseEntity<List<TeacherBean>>> getTeacherList(@Query("token") String token,@Body RequestBody body);

    //获取单条讲师数据
    @GET("course-center/teacher/{id}")
    Observable<BaseEntity<TeacherBean>> getTeacherDetails(@Path("id") String id,@Query("token") String token);

    //首页推荐列表
    @POST("bylBaseCenter/recommendinfo/search")
    Observable<BaseEntity<List<RecommendBean>>> getRecommendList(@Query("token") String token,@Body RequestBody body);

    //用户站内消息获取
    @POST("messagecenter/station/getStationUserMessageList")
    Observable<BaseEntity<List<MessageBean>>> getStationUserMessageList(@Query("token") String token, @Body()RequestBody requestBody);

    //站内消息获取
    @POST("messagecenter/station/getStationMessageList")
    Observable<BaseEntity<MessageBean>> getStationMessageList(@Query("token") String token, @Body()RequestBody requestBody);

    //消息读取后状态更新
    @GET("messagecenter/station/updateUserMessageReadFlag")
    Observable<BaseEntity<MessageBean>> updateUserMessageReadFlag(@Query("token") String token, @Query("id")String id);

    //用户信息
    @GET("bylBaseCenter/user/{userId}")
    Observable<BaseEntity<UserMsgBean>> getUserInfo(@Path("userId") String userId, @Query("token") String token);

    //用户信息修改
    @POST("bylBaseCenter/user/edit/{userId}")
    Observable<ResponseBody> eidtUser(@Path("userId") String userId, @Query("token") String token,@Body()RequestBody requestBody);



    /*----------------------支付------------------------------*/
    //支付宝支付
    @POST("/paycenter/paycenter/sendAliPayInfoByApp")
    Observable<ResponseBody> sendAliPayInfoByApp(@Query("token") String token, @Body()RequestBody requestBody);

    //微信
    @POST("/paycenter/paycenter/payWechatByApp")
    Observable<ResponseBody> payWechatByApp(@Query("token") String token, @Body()RequestBody requestBody);

    //课程购买
    @POST("course-center/course/buy/add")
    Observable<BaseEntity<BuyCourseBean>> buyCourse(@Query("token") String token, @Body()RequestBody requestBody);

    //课程购买
    @POST("paycenter/paycenter/orderCancel")
    Observable<BaseEntity> orderCancel(@Query("token") String token, @Body()RequestBody requestBody);

    //支付列表
    @POST("paycenter/paycenter/getPayList")
    Observable<List<PayStatusBean>> getPayList(@Query("token") String token, @Body()RequestBody requestBody);

    //支付状态获取
    @POST("paycenter/paycenter/getPayState")
    Observable<BaseEntity> getPayState(@Query("token") String token, @Body()RequestBody requestBody);

    //用户头像上传
    @POST("bylBaseCenter/user/uploading")
    Observable<BaseEntity> uploadPic(@Query("token") String token, @Body()RequestBody requestBody);


    //阿里云STS
    @GET("resource-center/common/getSTS")
    Observable<BaseEntity<STSBean>> getSTS(@Query("token") String token);

    //阿里云STS
    @GET("resource-center/common/getAliKey")
    Observable<BaseEntity<STSBean>> getAliKey(@Query("token") String token);

    //报名列表
    @POST("bylBusiness/signupuser/search")
    Observable<BaseEntity<List<SignUpBean>>> getSignUpList(@Query("token") String token, @Body()RequestBody requestBody);


}
